﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KinSocket;

namespace KinConquer.Packets.Structures
{
    public class HeroDataPacket
    {
        public Byte[] mData { get; private set; }
        public static explicit operator Byte[](HeroDataPacket d) { return d.mData; }

        public HeroDataPacket(Entities.Hero h)
        {
            String Spouse = "None";
            this.mData = new Byte[114 + h.Name.Length + Spouse.Length];

            PacketConstructor.Write((UInt16)(this.mData.Length), 0, mData);
            PacketConstructor.Write((UInt16)1006, 2, mData);

            PacketConstructor.Write(h.Identifier, 4, mData);
            PacketConstructor.Write(h.Lookface, 10, mData);
            PacketConstructor.Write(h.HairStyle, 14, mData);
            PacketConstructor.Write(h.Gold, 16, mData);
            PacketConstructor.Write(h.CP, 20, mData);
            PacketConstructor.Write(h.Experience, 24, mData);
            PacketConstructor.Write(h.Strength, 52, mData);
            PacketConstructor.Write(h.Agility, 54, mData);
            PacketConstructor.Write(h.Vitality, 56, mData);
            PacketConstructor.Write(h.Spirit, 58, mData);
            PacketConstructor.Write(h.StatPoints, 60, mData);

            PacketConstructor.Write(h.HitPoints, 62, mData);
            PacketConstructor.Write(h.ManaPoints, 64, mData);
            PacketConstructor.Write(h.PKPoints, 66, mData);

            PacketConstructor.Write(h.Level, 68, mData);
            PacketConstructor.Write(h.Class, 69, mData);
            PacketConstructor.Write(h.FirstClass, 70, mData);
            PacketConstructor.Write(h.SecondClass, 71, mData);
            PacketConstructor.Write(2, 72, mData);
            PacketConstructor.Write(h.Reborn, 73, mData);

            PacketConstructor.Write((UInt32)0, 75, mData); // Quiz Points
            PacketConstructor.Write((UInt16)0, 79, mData); // Enlighten Points

            PacketConstructor.Write((UInt16)h.Title, 91, mData);

            PacketConstructor.Write(h.CPB, 93, mData);

            PacketConstructor.Write(new List<String>
            {
                h.Name, "", Spouse
            }, 110, mData);
        }
    }
}
